<extend name='./Base' />
<block name='admin-content-body'>
  
  <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">站点留言</strong> / <small>Messages</small></div>
      </div>

      <hr>

      <div class="am-g">
        <div class="am-u-sm-12">
        <div class="am-panel am-panel-default">
        <div class="am-panel-bd">

  <div class="am-panel-bd am-collapse am-in am-cf" id="collapse-panel-3">
              <ul class="am-comments-list admin-content-comment">
                <foreach name='messages' item='me'>
                <li class="am-comment" id="message_{$me['id']}">
                  <a href="#"><img 
                  
                    <if condition="F('webSet')['qqLogin'] eq 1">
                      <if condition="($me['to'] neq 0) AND ($me['is_admin'] eq 1)">
                        src="__PUBLIC__/static/home/images/readerAvatar.png"
                      <elseif condition="($me['to'] neq 0) AND ($me['is_admin'] eq 0)" />
                        <if condition="!empty($me['avatar'])"> 
                          src="{$me['avatar']}"
                        <else /> 
                          src="__PUBLIC__/static/home/images/avatars/{$me['id']%10}.jpg"
                        </if>
                      <else />
                        <if condition="!empty($me['avatar'])"> 
                          src="{$me['avatar']}"
                        <else /> 
                          src="__PUBLIC__/static/home/images/avatars/{$me['id']%10}.jpg"
                        </if>
                      </if>
                    <else />
                      <if condition="($me['to'] neq 0) AND ($me['is_admin'] eq 1)">
                        src="__PUBLIC__/static/home/images/readerAvatar.png"
                      <elseif condition="($me['to'] neq 0) AND ($me['is_admin'] eq 0)" />
                        src="__PUBLIC__/static/home/images/avatars/{$me['id']%10}.jpg"
                      <else /> 
                        <if condition="!empty($me['avatar'])"> 
                          src="{$me['avatar']}"
                        <else /> 
                          src="__PUBLIC__/static/home/images/avatars/{$me['id']%10}.jpg"
                        </if>
                      </if>
                    </if>
                   class="am-comment-avatar" width="48" height="48"></a>
                  <div class="am-comment-main">
                    <header class="am-comment-hd">
                      <div class="am-comment-meta"><a href="#" class="am-comment-author" style="color: #0e90d2">
                        <if condition="($me['to'] neq 0) AND ($me['is_admin'] eq 1)"> 
   <!-- 站长回复 -->
    站长</a> &nbsp;&nbsp;回复&nbsp;&nbsp;{$me['replay']}
    <elseif condition="($me['to'] neq 0) AND ($me['is_admin'] eq 0)" />
    <!-- 不是站长回复 -->
    {$me['nickname']}</a> &nbsp;&nbsp;回复&nbsp;&nbsp;
      <if condition="$me['replay_admin'] eq 1">
      站长
      <else />
      {$me['replay']}
      </if>
    <else /> 
    <!-- 留言 -->
    {$me['nickname']}</a>
   </if>
                      &nbsp;&nbsp;&nbsp;时间：<time>{$me['create_time']|date='Y-m-d H:i:s',###}</time>
                      &nbsp;&nbsp;&nbsp;来自&nbsp;{$me['systemos']}的&nbsp;{$me['browser']}浏览器
                      </div>
                    </header>
                    <div class="am-comment-bd"><p>{$me['message']}</p>
                    </div>
                    <div class="am-comment-footer am-comment-actions" style="cursor: pointer;">
          <span onclick="replay({$me['id']},'{$me['nickname']}')"><i class="am-icon-reply"></i>回复</span>
          &nbsp;&nbsp;&nbsp;<i class="am-icon-thumbs-up"></i>点赞[{$me['upm']}]&nbsp;&nbsp;&nbsp;<i class="am-icon-thumbs-down"></i>点踩[{$me['downm']}]
                    <div style="float: right;color: red;cursor: pointer;"><span onclick="deletec({$me['id']})"><i class="am-icon-trash-o"></i>删除</span>
                    </div>
                  </div>
                </li>
  </foreach>
              </ul>
            </div>

        </div>
      </div>
        
            <div class="am-fr">
                {$pager}
              </div>
        </div>

      </div>
    </div>

</block>

<block name="js">
  <script type="text/javascript">
   function replay(id,nickname){
    layer.prompt({title: '回复'+nickname, formType: 2}, function(text, index){
      layer.close(index);
        $.post('{:U("messages/replay")}',{'message':text,'id':id},function(res){
          if(res.status){
            layer.msg(res.msg);
          }else{
            layer.alert(res.msg);
          }
        });
    });
  }
   function deletec(id) {
      layer.confirm('确定要删除？不可恢复', {
        btn: ['确定','取消']
      },function(){
        $.post('{:U("messages/deletemsg")}',{'id':id,'delete':1},function(res){
          if(res.status){
            $("#message_"+id).remove();
            layer.msg(res.msg);
          }else{
            layer.alert(res.msg,{icon:5});
          }
        });
    },function(){})
   } 
  </script>
</block>